<?php

use Phalcon\Mvc\Controller;

class ControllerBase extends Controller
{

    /**
     * json 返回
     * @param bool $status
     * @param string $message
     * @param null $data
     * @param null $token
     */
    public function exitMessage($status = false, $message = '', $data = null, $token = null)
    {
        $info = new stdClass();
        $info->status = $status;
        $info->message = $message;
        $info->data = $data;
        if ($token) {
            $info->token = $token;
        }
        header('Content-type:application/json');
        exit(json_encode($info, JSON_UNESCAPED_UNICODE|JSON_NUMERIC_CHECK|JSON_PRESERVE_ZERO_FRACTION));
    }

}
